<?php

class user_model extends CI_Model{
    function __construct() {
        parent::__construct();
    }
    
    function get_user_detail($username)
    {
        $query = $this->db->get_where('user', array('username' => $username));
        $result = $query->result();

        if (count($result) > 0) {
            return $result[0];
        } else {
            return NULL;
        }
    }
    
    function get($username,$pass)
    {
        $query = $this->db->get_where('user', array('username' => $username,'pass'=>$pass));
        $result = $query->result();

        if (count($result) > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    
    function edit($username,$pass,$displayname)
    {
        $data = array(            
            'pass' => $pass,
            'displayname' => $displayname
        );
        $this->db->where('username', $username);
        $this->db->update('user', $data);
        if ($this->db->affected_rows() > 0) {
            return true;
        } else {
            return false;
        }
    }
}
?>
